package com.sm.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

@Component
public class Attendance extends BaseEntity {
    private Integer aid;
    private Integer uid;
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GTM+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date date;
    private String dateStr;
    @JsonFormat(pattern = "HH:mm:ss")
    @DateTimeFormat(pattern = "HH:mm:ss")
    private Date starttime;
    @JsonFormat(pattern = "HH:mm:ss")
    @DateTimeFormat(pattern = "HH:mm:ss")
    private Date endtime;
    private Integer status;// 1 正常 2 迟到 3 旷工 4 请假
    private Integer month;//当前月份
    @JsonFormat(pattern = "HH:mm:ss")
    @DateTimeFormat(pattern = "HH:mm:ss")
    private Date ostime;//加班开始时间
    @JsonFormat(pattern = "HH:mm:ss")
    @DateTimeFormat(pattern = "HH:mm:ss")
    private Date oetime;//加班结束时间
    private Integer sign;//是否加班    默认0 没加班 1 晚上加班  2 周末加班 3 节假日加班
    private Integer flag;//是否下班签到了
    private UserInfo userInfo;//考勤用户

    public Attendance(){
        Calendar calendar = new GregorianCalendar();
        int mm = calendar.get(Calendar.MONTH);
        this.month = (mm+1)%3;
    }

    public Integer getAid() {
        return aid;
    }

    public void setAid(Integer aid) {
        this.aid = aid;
    }

    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        this.dateStr = simpleDateFormat.format(this.date);
    }

    public String getDateStr() {
        return dateStr;
    }

    public void setDateStr(String dateStr) {
        this.dateStr = dateStr;
    }

    public Date getStarttime() {
        return starttime;
    }

    public void setStarttime(Date starttime) {
        this.starttime = starttime;
    }

    public Date getEndtime() {
        return endtime;
    }

    public void setEndtime(Date endtime) {
        this.endtime = endtime;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getMonth() {
        return month;
    }

    public void setMonth(Integer month) {
        this.month = month;
    }

    public Date getOstime() {
        return ostime;
    }

    public void setOstime(Date ostime) {
        this.ostime = ostime;
    }

    public Date getOetime() {
        return oetime;
    }

    public void setOetime(Date oetime) {
        this.oetime = oetime;
    }

    public Integer getSign() {
        return sign;
    }

    public void setSign(Integer sign) {
        this.sign = sign;
    }

    public Integer getFlag() {
        return flag;
    }

    public void setFlag(Integer flag) {
        this.flag = flag;
    }

    public UserInfo getUserInfo() {
        return userInfo;
    }

    public void setUserInfo(UserInfo userInfo) {
        this.userInfo = userInfo;
    }

    @Override
    public String toString() {
        return "Attendance{" +
                "aid=" + aid +
                ", uid=" + uid +
                ", date=" + date +
                ", dateStr='" + dateStr + '\'' +
                ", starttime=" + starttime +
                ", endtime=" + endtime +
                ", status=" + status +
                ", month=" + month +
                ", ostime=" + ostime +
                ", oetime=" + oetime +
                ", sign=" + sign +
                ", flag=" + flag +
                ", userInfo=" + userInfo +
                '}';
    }
}
